import 'package:x3_base_core/base_enums/base_http_access_model_enum.dart';
import 'package:x3_base_core/base_models/base_http_request_model.dart';
import 'package:x3_base_core/base_utils/base_dio_code_util.dart';

class BaseFormTransformUtil {
  /// 获取入参中的 accessMode 不为 WebHidden 的列
  static List<BaseHttpRequestModel> getShowRequestModels(List<BaseHttpRequestModel> result) {
    return result.where((element) => element.accessMode != BaseHttpAccessModelEnum.WebHidden).toList();
  }

  /// 把List<dynamic>集合数据转成List<BaseHttpRequestModel>集合数据
  static List<BaseHttpRequestModel> transformToListRequestData(List<dynamic> data) {
    List<BaseHttpRequestModel> requests = [];
    List<Map<String, dynamic>> maps = BaseDioCodeUtil.dynamicListToMapList(data);
    for (int i = 0; i < maps.length; i++) {
      Map<String, dynamic> json = maps[i];
      BaseHttpRequestModel model = BaseHttpRequestModel.fromJson(json);
      requests.add(model);
    }
    return requests;
  }
}
